﻿
namespace EventBusNet6.Controllers
{
    [Route("api")]
    [ApiController]
    public class LibreOfficeController : ControllerBase
    {
        private readonly Serilog.ILogger _logger = Log.Logger;
        private readonly ILibreOfficeService _libreOfficeService;
        public LibreOfficeController(ILibreOfficeService libreOfficeService)
        {
            _libreOfficeService = libreOfficeService;
        }
        /// <summary>
        /// office文件转pdf
        /// </summary>
        /// <returns></returns>
        [HttpPost("office2pdf")]
        public ApiResult Office2PDF(Office2PdfInput input)
        {
            Office2PdfOutput output = new Office2PdfOutput();
            var guid = Guid.NewGuid().ToString();
            output.Guid = guid;
            output.CatalogFile = _libreOfficeService.ConvertPDF(input.OfficePath, guid);

            return FormatterResult.Success(output);
        }
        /// <summary>
        /// office文件首页图片
        /// </summary>
        /// <returns></returns>
        [HttpPost("office2firstjpg")]
        public  ApiResult Office2FirstJpg(Office2FirstJpgInput input)
        {
            Office2FirstJpgOutput output = new Office2FirstJpgOutput();
            var guid = Guid.NewGuid().ToString();
            output.Guid = guid;
            output.CatalogFile = _libreOfficeService.ConvertFirstJpg(input.OfficePath, guid);
            return FormatterResult.Success(output);
        }
    }
}
